package service.impl;

import mapper.StudentMapper;
import model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.StudentService;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    StudentMapper studentMapper;
    @Override
    public List<Student> findAll() {
        return studentMapper.selectAll();
    }

    @Override
    public void save(Student student) {
         studentMapper.insert(student);
    }

    @Override
    public Student findById(int id) {
        return studentMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(int id, Student student) {
        studentMapper.updateByPrimaryKey(student);
    }

    @Override
    public void remove(int id) {
        studentMapper.deleteByPrimaryKey(id);
    }
}
